import type { Address } from '@/types/address'
import { http } from '@/utils/http'

//新建收货地址
export const createAddress = (address: Address) => {
  return http({
    url: '/member/address/insert',
    method: 'POST',
    data: address,
  })
}

//获取收获地址列表
export const getAddressListAPI = (userId: number) => {
  return http<Address[]>({
    url: '/member/address/findByUserId',
    method: 'POST',
    data: userId + '', //注意：这里要把userId转化成字符串
  })
}

//获取收获地址详情
export const getAddressDetailAPI = (id: number) => {
  return http<Address>({
    url: '/member/address/findById',
    method: 'POST',
    data: id + '', //注意：这里要把id转化成字符串
  })
}

//修改收货地址
export const updateAddressAPI = (address: Address) => {
  return http({
    url: '/member/address/update',
    method: 'POST',
    data: address,
  })
}

//删除收货地址
export const deleteAddressAPI = (id: number) => {
  return http({
    url: '/member/address/del',
    method: 'POST',
    data: id + '', //注意：这里要把id转化成字符串
  })
}
